package eu.telecombretagne.rsm.base.entity;

import eu.telecombretagne.rsm.base.event.*;
import eu.telecombretagne.rsm.gui.frames.DesktopFrame;


public class AppReceiverEntity extends Entity implements Runnable {

	static private Class<?> [] producedEvents = {};
	static private Class<?> [] consumedEvents = {AppMessageEvent.class};
	
	public AppReceiverEntity (EventChannel ec) {
		super (ec, producedEvents, consumedEvents);
	}
	
	public void run(){
		while (runSwitch) {
			try {
				Event e = this.consume ();
				if (e.getClass () == AppMessageEvent.class) {
					AppMessageEvent ame = (AppMessageEvent) e;
					
					DesktopFrame.writeLogReceiver("AppReceiverEntity: receiving " + ame.getBody ());
				}
			}
			catch (InterruptedException ie) {
				DesktopFrame.writeLogError("AppReceiverEntity" + ie);
				System.exit(1);
			}
		}
	}
}